#coding=utf-8
"""
Author:高鑫
Time:2025/8/28 0028 10:58
"""

import yaml
from config.config import *
import os

class Read_Yaml():
    def __init__(self,file_path):
        self.file_path = file_path
        self.data = None

    def load_data_yaml(self):
        try:
            with open(self.file_path,'r',encoding="utf-8")as f:
                self.data = yaml.safe_load(f)
            print("YAML 加载成功")
        except FileNotFoundError:
            print(f"错误：文件{self.file_path}未找到")
        except yaml.YAMLError as e:
            print(f"错误：解析 YAML 文件时错误-{e}")
        except Exception as e:
            print(f"位置错误：{e}")
    def get_data_yaml(self):
        if self.data is None:
            print("尚未加载 YAML 文件 请先调用load_data_yaml 方法")
            return None
        return self.data

file = os.path.join(data_path,'data.yaml')
yaml_read = Read_Yaml(file)
yaml_read.load_data_yaml()
data = yaml_read.get_data_yaml()
print(data['url'])


























